<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- 查询区域 -->
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <!--    <div class="table-operator" v-if="mainId">-->
    <!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
    <!--      <a-button type="primary" icon="download" @click="handleExportXls('工单bom从表')">导出</a-button>-->
    <!--      <a-upload-->
    <!--        name="file"-->
    <!--        :showUploadList="false"-->
    <!--        :multiple="false"-->
    <!--        :headers="tokenHeader"-->
    <!--        :action="importExcelUrl"-->
    <!--        @change="handleImportExcel">-->
    <!--        <a-button type="primary" icon="import">导入</a-button>-->
    <!--      </a-upload>-->
    <!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
    <!--        <a-menu slot="overlay">-->
    <!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
    <!--        </a-menu>-->
    <!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
    <!--      </a-dropdown>-->
    <!--    </div>-->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'MesBomItemWoList',
  mixins: [JeecgListMixin],
  components: {},
  props: {
    mainId: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['woid'] = val
          this.loadData(1)
        }
      }
    }
  },
  data() {
    return {
      description: '工单BOM',
      disableMixinCreated: true,
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          fixed: 'left',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },

        {
          title: '物料',
          align: 'center',
          fixed: 'left',
          dataIndex: 'itempartno'
        },

        {
          title: '英文描述',
          align: 'center',
          fixed: 'left',
          dataIndex: 'descEn'
        },
        {
          title: '本地描述',
          align: 'center',
          fixed: 'left',
          dataIndex: 'descLocal'
        },
        {
          title: '产品版本',
          align: 'center',
          dataIndex: 'rev'
        },
        {
          title: '物料版本',
          align: 'center',
          dataIndex: 'itemrev'
        },
        {
          title: '图号',
          align: 'center',
          dataIndex: 'drawing'
        },
        {
          title: '消耗数量',
          align: 'center',
          dataIndex: 'qtyPer'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'unit'
        },
        {
          title: '工位',
          align: 'center',
          dataIndex: 'op'
        },
        {
          title: '是否重用',
          align: 'center',
          dataIndex: 'reuse'
        },
        {
          title: '条码校验规则',
          align: 'center',
          dataIndex: 'idpattern'
        },
        {
          title: '条码名称',
          align: 'center',
          dataIndex: 'idname'
        },
        {
          title: '是否引领条码',
          align: 'center',
          dataIndex: 'leadno'
        },
        {
          title: '是否扣减物料',
          align: 'center',
          dataIndex: 'lottrack'
        },
        {
          title: '启用状态',
          align: 'center',
          dataIndex: 'enable'
        },
        {
          title: '是否共享物料',
          align: 'center',
          dataIndex: 'shared'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status'
        },
        {
          title: 'Block limit,less than 0 or null means not block',
          align: 'center',
          dataIndex: 'blocklimit'
        },
        {
          title: '预警阈值',
          align: 'center',
          dataIndex: 'warninglimit'
        },
        {
          title: '拉动数量',
          align: 'center',
          dataIndex: 'qtyPull'
        }
        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   align: 'center',
        //   fixed: 'right',
        //   width: 147,
        //   scopedSlots: {customRender: 'action'}
        // }
      ],
      url: {
        list: '/trace/mesWoSrcTrace/listMesBomItemWoByMainId'
      },
      dictOptions: {}
    }
  },
  created() {
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
    }
  },
  methods: {
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
